package stardust.product.platform.webc.support;


import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import stardust.core.io.IOUtils;
import stardust.core.network.protocol.http.HttpMethod;


public class HTTPSupport
{

  public static void post(URL url, InputStream inputStream) throws IOException
  {
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    
    connection.setDoInput(true);
    connection.setDoOutput(true);
    connection.setInstanceFollowRedirects(true);
    connection.setRequestMethod(HttpMethod.post.value);
    connection.setFixedLengthStreamingMode(inputStream.available());
    
    IOUtils.readToWrite(inputStream, connection.getOutputStream());
    
    inputStream.close();
    connection.disconnect();
  }

}
